<%@ page import="cn.edu.usst.cs.chat_room01.HelloServlet" %>
<%@ page import="cn.edu.usst.cs.chat_room01.ServletInterface" %><%--
  Created by IntelliJ IDEA.
  User: jerry
  Date: 11/1/2024
  Time: 13:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>欢迎加入聊天室</title>
</head>
<body>
<%
    DISPLAY_BODY:{
        Object user_raw = request.getSession().getAttribute(HelloServlet.USER);
        if (user_raw == null) {
%>
<a href="index.jsp"> 会话超时，请重新登录 </a>
<%
        break DISPLAY_BODY;
    }
    String user = user_raw.toString();
    Object warning_attr = request.getSession().getAttribute("warning");
%>
<h1 id="user_display_head"><%=user %> 的聊天室 </h1>

<div id="main_div">
    <label for="messages_display">
    <textarea id="messages_display" readonly>
                消息获取中
                </textarea>
    </label>
    <br/>
    <form action="chatroom" method="post">
        <fieldset>
            <label for="RECEIVER">
                发送给
                <select id="RECEIVER" name="RECEIVER" class="select">
                    <option label="加载中"> 加载中</option>
                </select>
            </label>
            <br/>
            <label for="message">
                <input id="message" name="message" type="text">
            </label>
            <label for="user_id_hidden" style="display: none">
                <input id="user_id_hidden" name="SENDER" value="<%=user%>">
            </label>
            <br/>
            <button type="submit">发送</button>
        </fieldset>
    </form>
</div>
<script type="text/javascript" src="chatroom.js?<%= System.currentTimeMillis() %>"></script>
<%
    if (warning_attr != null) {
%>
<script type="text/javascript">
    alert("<%=warning_attr%>")
</script>
<%
        }
    }

%>
</body>
</html>
